/*
 * $Id$
 *
 * Copyright ( c ) 2014 XuNuo Corporation. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of XuNuo
 * Corporation ("Confidential Information").  You shall not disclose such
 * Confidential Information and shall use it only in accordance with the terms
 * of the license agreement you entered into with XuNuo Corporation or a XuNuo
 * authorized reseller (the "License Agreement"). XuNuo may make changes to the
 * Confidential Information from time to time. Such Confidential Information may
 * contain errors.
 *
 * EXCEPT AS EXPLICITLY SET FORTH IN THE LICENSE AGREEMENT, XuNuo DISCLAIMS ALL
 * WARRANTIES, COVENANTS, REPRESENTATIONS, INDEMNITIES, AND GUARANTEES WITH
 * RESPECT TO SOFTWARE AND DOCUMENTATION, WHETHER EXPRESS OR IMPLIED, WRITTEN OR
 * ORAL, STATUTORY OR OTHERWISE INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A
 * PARTICULAR PURPOSE. XuNuo DOES NOT WARRANT THAT END USER'S USE OF THE
 * SOFTWARE WILL BE UNINTERRUPTED, ERROR FREE OR SECURE.
 *
 * XuNuo SHALL NOT BE LIABLE TO END USER, OR ANY OTHER PERSON, CORPORATION OR
 * ENTITY FOR INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL
 * DAMAGES, OR DAMAGES FOR LOSS OF PROFITS, REVENUE, DATA OR USE, WHETHER IN AN
 * ACTION IN CONTRACT, TORT OR OTHERWISE, EVEN IF XuNuo HAS BEEN ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES. XuNuo' TOTAL LIABILITY TO END USER SHALL NOT
 * EXCEED THE AMOUNTS PAID FOR THE XuNuo SOFTWARE BY END USER DURING THE PRIOR
 * TWELVE (12) MONTHS FROM THE DATE IN WHICH THE CLAIM AROSE.  BECAUSE SOME
 * STATES OR JURISDICTIONS DO NOT ALLOW LIMITATION OR EXCLUSION OF CONSEQUENTIAL
 * OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT APPLY TO END USER.
 *
 * Copyright version 2.0
 */
package com.th.supcom.pds.recipefee.client.widget;

import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Label;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.th.supcom.pds.common.client.widget.PdsLayoutContainer;
import com.th.supcom.pds.internal.client.widget.MedicareCardField;

/**
 * 收方收费患者基本信息面板
 * 
 * @author 杨冲
 */
public class RecipeFeePatientInfoPanel extends ContentPanel
{
    /** 提交路径. */
    public static final String SCC_BRANCH = "$URL$";
    /** 提交日期. */
    public static final String SCC_LAST_MODIFICATION_DATE = "$Date$";
    /** 最终修改人员. */
    public static final String SCC_LAST_MODIFIER_NAME = "$Author$";

    /** 最终版本号. */
    public static final String SCC_REVISION = "$Revision$";

    private MedicareCardField m_cardField;

    private final RecipeFeeButtons m_recipeFeeButtons;

    private final RecipeFeeFields m_recipeFeeFields;

    /**
     * 构造函数
     */
    public RecipeFeePatientInfoPanel (final RecipeFeeFields recipeFeeFields, final RecipeFeeButtons buttons)
    {
        m_recipeFeeFields = recipeFeeFields;
        m_recipeFeeButtons = buttons;
    }

    /**
     * 添加刷卡组件
     * 
     * @param medicareCardField
     */
    public void addMedicareCard (final MedicareCardField medicareCardField)
    {
        m_cardField = medicareCardField;
    }

    /**
     * 初始化UI
     */
    public void initUI ()
    {
        FieldSet patientInfoFieldSet;
        FieldSet queryFieldSet;
        this.setBodyBorder (false);
        this.setFrame (true);
        this.setHeaderVisible (false);
        this.setLayout (new FormLayout ());

        queryFieldSet = new FieldSet ();
        queryFieldSet.setHeading ("收方");
        queryFieldSet.setLayout (new FormLayout ());

        final PdsLayoutContainer queryContainer = new PdsLayoutContainer ();
        queryContainer.insertWidget (m_cardField, 24);
        queryContainer.insertWidget (m_recipeFeeFields.getRecipeNoField (), 24);
        queryContainer.insertWidget (m_recipeFeeFields.getStartField (), 24);
        queryContainer.insertWidget (m_recipeFeeFields.getEndField (), 24);

        queryContainer.insertWidget (new Label (), 4);
        queryContainer.insertWidget (m_recipeFeeButtons.getQueryBtn (), 4);
        queryContainer.init ();
        queryFieldSet.add (queryContainer);
        add (queryFieldSet);

        patientInfoFieldSet = new FieldSet ();
        patientInfoFieldSet.setHeading ("患者基本信息");
        patientInfoFieldSet.setLayout (new FormLayout ());

        final PdsLayoutContainer container = new PdsLayoutContainer ();
        container.insertWidget (m_recipeFeeFields.getPrescSource (), 1);
        container.insertWidget (m_recipeFeeFields.getNameField (), 1);
        container.insertWidget (m_recipeFeeFields.getPatientIdField (), 1);
        container.insertWidget (m_recipeFeeFields.getSexField (), 1);
        container.insertWidget (m_recipeFeeFields.getBirthDayField (), 1);
        container.insertWidget (m_recipeFeeFields.getBalanceField (), 1);
        container.init ();

        final PdsLayoutContainer container2 = new PdsLayoutContainer ();
        container2.insertWidget (m_recipeFeeFields.getVisitTypeNameField (), 1);
        container2.insertWidget (m_recipeFeeFields.getVisitIdField (), 1);
        container2.insertWidget (m_recipeFeeFields.getVisitBeginDateField (), 1);
        container2.insertWidget (m_recipeFeeFields.getDeptNameField (), 1);
        container2.insertWidget (m_recipeFeeFields.getDay (), 1);
        container2.insertWidget (m_recipeFeeFields.getNumber (), 1);
        container2.init ();
        patientInfoFieldSet.add (container);
        patientInfoFieldSet.add (container2);
        add (patientInfoFieldSet);
        m_cardField.focus ();
    }
}
